<?php
Class Admin extends CI_Model
{
	public $table = 'admin';
	public $primary_key = 'ad_uname';
	
	function login($username, $password)
	{
		$this->db->select('ad_id as id, ad_uname as uname, ad_pwd, ad_name as name, ad_type as type');
		$this->db -> from('admin');
		$this -> db -> where('ad_uname', $username);
		$this -> db -> where('ad_pwd', MD5($password));
		$this -> db -> limit(1);

		$query = $this -> db -> get();

		if($query -> num_rows() == 1)
		{
			return $query->result();
		}
		else
		{
			return false;
		}
	}
	
	function insert($value){
		return $this->db->insert($this->table, $value);
	}
	
	function update($value, $where){
		return $this->db->update($this->table, $value, $where);
	}
}
?>